/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */
class LoginFilters {
    def filters = {
        authFilter(controller:'*', action:'*') {
            before = {
                if(!session.user && !actionName.equals('login')&& !actionName.equals('createAdmin')&& !actionName.equals('auth')) {
                    redirect(controller:'auth', action:'login')
                    return false
                }
            }
        }

        userFilter(controller:'user', action:'create|save|update|delete|edit|upload'){
            before = {
                if(!session.user.role.equals('admin')){
                    redirect(controller:'auth', action:'login')
                    return false
                }
            }
        }

    }
}

